Date.prototype.format = function (tim) {
    var times = Date.parse(new Date());
    let time = (times - tim) / 1000;
    if (time < 60 * 10) {//十分钟内
        return '刚刚';
    } else if ((time < 60 * 60) && (time >= 60 * 10)) {//超过十分钟少于1小时
        s = Math.floor(time / 60);
        return s + "分钟前";
    } else if ((time < 60 * 60 * 24) && (time >= 60 * 60)) {//超过1小时少于24小时
        s = Math.floor(time / 60 / 60);
        return s + "小时前";
    } else if ((time < 60 * 60 * 24 * 3) && (time >= 60 * 60 * 24)) {//超过1天少于3天内
        s = Math.floor(time / 60 / 60 / 24);
        return s + "天前";
    } else {//超过3天
        let date = new Date(tim);
        let y = date.getFullYear();//年
        let m = date.getMonth() + 1;//月
        m = m < 10 ? "0" + m : m;
        let d = date.getDate();//日
        d = d < 10 ? "0" + d : d;
        let h = date.getHours();//时
        h = h < 10 ? "0" + h : h;
        let minute = date.getMinutes();//分
        return y + "年" + m + "月" + d + "日" + h + "时" + minute + "分"
    }
}

Date.prototype.followTime = function () {
    var date = new Date(this);
    var Y = date.getFullYear();
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
    var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
    var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
    var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
    var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
    return  M + '月' + D + '日 ' + h + '时' + m + '分';
}